Repository navigation
[libcudacxx] Add debugger pretty-printers for cuda::std::optional - #10843
theo-bermudez wants to merge 2 commits into
Conversation
Adds GDB and LLDB pretty-printers for cuda::std::optional, following the pattern of the existing array, tuple, and span printers (NVIDIA#10528, NVIDIA#10534, NVIDIA#10699), plus a test scenario under test/debugging/optional. The disengaged state is rendered without dereferencing the payload storage; optional<T&> is handled through its pointer member. Closes NVIDIA#10093.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan includes up to 12 reviews per rolling hour; 11 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesDebugger optional support
Assessment against linked issues
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change adds debugger display support for cuda::std::optional without changing runtime behavior; no actionable merge-blocking risk remains after normal checks and review. Comment |
miscco
left a comment
There was a problem hiding this comment.
Looks good, just one nit regarding detection with our inline ABI namespaces
| def _is_cuda_optional(value_type: gdb.Type) -> bool: | ||
| value_type = cccl_common.canonical_type(value_type) | ||
| template_name = cccl_common.template_name(cccl_common.public_type_name(value_type)) | ||
| return template_name == "cuda::std::optional" |
There was a problem hiding this comment.
I am not sure whether this works with our inline namespaces
| return template_name == "cuda::std::optional" | |
| return ( | |
| public_name.startswith("cuda::std::") | |
| and template_name.rsplit("::", 1)[-1] == "optional" | |
| ) |
There was a problem hiding this comment.
Good catch — applied in 958dcd2, mirroring the array/tuple detection pattern. ctest -R 'debugging.*optional' still passes 2/2 and the .expected goldens are unchanged.
Match the array/tuple detection pattern: check the ABI-stripped name prefix and the last template-name component instead of an exact match, so detection survives namespace forms the strip pattern doesn't know.
|
Superseded by #10847, which merged the same GDB/LLDB optional pretty-printer support and debugger test coverage. Closing this older duplicate to keep the review queue clear. Thanks for the review here. |
Description
Closes #10093.
What
Adds GDB and LLDB pretty-printers for
cuda::std::optional, following the patternestablished by the existing
array(#10528),tuple(#10534), andspan(#10699)printers. New printers live at
libcudacxx/share/libcudacxx/{gdb,lldb}/optional.py,registered in each
__init__.py, with a test scenario underlibcudacxx/test/debugging/optional/.Correctness note
The disengaged state is rendered without dereferencing the payload storage: both
printers read only the engaged flag (
__engaged_) before deciding whether to exposethe contained value. The
optional<T&>specialization stores a pointer instead, so itis detected via its
__value_member and reported disengaged when the pointer is null.Coverage includes engaged, disengaged, nested optional (engaged and disengaged inner),
a non-trivially-destructible payload, an alias, both engaged and disengaged
optional<int&>, and re-inspection afterreset().Verification
The
.expectedfixtures were generated by running the real debuggers through the testharness (
run_pretty_printer_test.py --update-expected). Environment: aarch64 Linuxcontainer, CUDA Toolkit 13.3, gdb 15.1, lldb 18.1.3 (no GPU; these scenarios are
host-only).
arrayscenario still passes unchanged (ctest -R 'debugging.*array',2/2).
pre-commitpasses on all changed files.optional.update.before/optional.update.aftercases lock thereset()edge inregression: after
reset()leaves stale payload bytes in__val_, both debuggersrender the optional as empty rather than surfacing the stale value.
Checklist